package tc.alert.tckejisoc.kafka.service;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

// DataConsumer.java
@Component
@Slf4j
public class DataConsumer {

    @Autowired
    private MessageProcessor messageProcessor;

//    @KafkaListener(
//            topics = "topics-ty",
//            groupId = "your_group_id",
//            properties = {
//                    "auto.offset.reset=latest"  // 关键配置
//            }
//    )
    public void consume(ConsumerRecord<String, String> record) {
        // 仅记录接收信息，实际处理交给线程池
        log.debug("Received record [key={}, partition={}]",
                record.key(), record.partition());
        messageProcessor.process(record);
    }
}